package com.heima.osstest;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.PutObjectResult;

import java.io.FileInputStream;

/**
 * @author lo
 * @date 2021/9/22
 */
public class Mytest {
    public static void main(String[] args) throws Exception{
        // Endpoint以杭州为例，其它Region请按实际情况填写。
        String endpoint = "http://oss-cn-shanghai.aliyuncs.com";
        // 阿里云主账号AccessKey拥有所有API的访问权限，风险很高。
        String accessKeyId = "LTAI5tLK2HoYeicMw1NR4Sht";
        String accessKeySecret = "C2HdI3tgDNXL6UyL9qPBg5DfpMmKb6";

        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

        // 上传Byte数组。
        FileInputStream inputStream = new FileInputStream("D:\\桌面优化\\lovewallpaper\\2.jpg");
        PutObjectResult result = ossClient.putObject("container-one", "material/b.jpg", inputStream);

        // 关闭OSSClient。
        ossClient.shutdown();



    }
}
